package com.dks.controller;

import com.dks.dto.DoctorDto;
import com.dks.models.Doctor;
import com.dks.models.TalksRecord;
import com.dks.repository.IDoctorRepository;
import com.dks.repository.ITalksRecordRepository;
import com.dks.result.ResultModel;
import com.dks.util.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 医生账号相关
 */
@RestController
@RequestMapping("doctor")
public class DoctorController {

    @Resource
    private IDoctorRepository doctorRepository;


    /**
     * 医生登录
     * @param doctor 医生信息
     * @author zn
     */
    @PostMapping("login")
    public ResultModel<Boolean> login(@RequestBody Doctor doctor){
        return doctorRepository.login(doctor);
    }

    /**
     * 密码重置
     * @param doctor 医生信息
     * @author zn
     */
    @PostMapping("reset")
    public ResultModel<Boolean> reset(@RequestBody Doctor doctor){
        return doctorRepository.reset(doctor);
    }

    /**
     * 密码修改
     * @param doctorDto 医生信息
     * @author zn
     */
    @PostMapping("updatePwd")
    public ResultModel<Boolean> updatePwd(@RequestBody DoctorDto doctorDto){
        return doctorRepository.updatePwd(doctorDto);
    }

    /**
     * 新增账号
     * @param doctor 记录
     * @author zn
     */
    @PostMapping("insert")
    public ResultModel<Boolean> insert(@RequestBody Doctor doctor){
        return doctorRepository.insert(doctor);
    }

    /**
     * 修改医生信息
     * @param doctor 医生信息
     * @author zn
     */
    @PostMapping("update")
    public ResultModel<Boolean> update(@RequestBody Doctor doctor)  {
        return doctorRepository.update(doctor);
    }


    /**
     * 医生列表查询
     * @param departmentId 科室id
     * @author zn
     */
    @GetMapping("selectDocterListByDepartmentId")
    public ResultModel<Boolean> selectDocterListByDepartmentId(@Param("departmentId") Integer departmentId)  {
        return doctorRepository.selectDocterListByDepartmentId(departmentId);
    }


}
